<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/4/1
 * Time: 12:54
 */

class AdService extends BaseService
{
    private $confModel;
    private $orderModel;
    private $userInfoModel;
    private $mUser;

    public function _initialize()
    {
        parent::_initialize();
        $this->mUser = D("User");
    }


    //广告
    function adver($accountId,$str='bottom',$module=''){
        $module = strtolower($module);
        $adOb = M('WapAdPlace');
        $where = array('tags'=>$module.'_'.$str,'account_id' => $accountId,'cut_off' => 0);
        $placeId = $adOb -> where($where) ->getField('place_id');
        if(!isset($_SESSION['userType'])){
            $userId = session('userId');
            $userType = D('user')->getInfo(array('user_id' => $userId),'type');
            session('userType',$userType['type']);
        }   

        $type = !empty($_SESSION['userType']) ? session('userType') : 2 ;

        $adModel = D('Base/WapAd');
        $condition = array(
            'place_id'=>$placeId,
            'account_id'=>$accountId,
            'cut_off' => 0,
            'object' => array('like','%'.$type.'%'),
            );
        $adInfo = $adModel->getList($condition,'','sort');
        return $adInfo;
    }
    
  
}